package com.study.homework.oom;

/**
 * 测试虚拟机栈和本地方法栈溢出
 *
 * vm 参数: -Xss128k
 * @author andys
 *
 */

public class JavaVMStackSOF {
	
	private int stackLength=1;
	
	public void stackLeak(){
		stackLength++;
		stackLeak();
	}
	
	/**
	 * stack length:998
	 *	Exception in thread "main" java.lang.StackOverflowError
	 *  at com.study.homework.oom.JavaVMStackSOF.stackLeak(JavaVMStackSOF.java:15)
	 *  .....
	 */
	public static void main(String[] args) {
		
		JavaVMStackSOF obj= new JavaVMStackSOF();
		
		try {
			obj.stackLeak();
		} catch (Throwable e) {
			System.out.println("stack length:" + obj.stackLength);
			throw e;
		}
	}
	
}
